#include<bits/stdc++.h>
using namespace std;
#define int long long
int T;
bitset<30005>bit;
int a[30005], len;
int b[30005];
int x[30005];
set<int>st;
signed main(){
    freopen("kte.in", "r", stdin);
    freopen("kte.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin >> T;
    int ok = 1;
    if(T > 30000)ok = 0;
    for(int i = 1; i <= T; i++){
        cin >> x[i];
        if(x[i] > 30000){
            ok = 0;
        }
    }
    for(int _ = 1; _ <= T; _++){
        int x_ = x[_];
        len = 0;
        if(ok){
            bit[x_] = bit[x_] ^ 1;
            for(int i = bit._Find_first(); i != bit.size(); i = bit._Find_next(i))a[++len] = i;
        }else{
            if(st.find(x_) != st.end())st.erase(x_);
            else st.insert(x_);
            for(auto i : st)a[++len] = i;
        }
        for(int i = 1; i <= len; i++)b[i] = a[len - i + 1];
        a[0] = b[len + 1] = 0;
        int L, R;
        L = -1;
        int ans = 0;
        for(int i = 1; i <= len; i++){
            a[i] += a[i - 1];
            b[i] += b[i - 1];
            if(L == -1 || R < a[i]){
                ans += b[i] - a[i];
                L = a[i], R = b[i] - 1;
            }else{
                ans += b[i] - 1 - R;
                R = b[i] - 1;
            }
        }
        cout << ans << '\n';
    }
    return 0;
}